#!/bin/bash

# shellcheck source=/dev/null
source "${JAliasSrc:?}/scripts/tool.bash"

# remove cache
if [ -e "${JAliasStorePath?:}" ]; then
    rm -rf "$JAliasStorePath"
    printf "\033[32m%s\033[0m %s\n" "● data path removed! " "$JAliasStorePath"
fi

rc_file="$(shell_rc_file)"

# unregister env
if sed -i '' "s#^source ${JAliasSrc:?}/scripts/jalias_env.sh##g" "$rc_file"; then
    printf "\033[32m%s\033[0m %s\n" "● source removed from " "$rc_file"
fi

# remove source path
if [ -e "$JAliasSrc" ]; then
    rm -rf "$JAliasSrc"
    printf "\033[32m%s\033[0m %s\n" "● src removed! " "$JAliasSrc"
fi

# shellcheck disable=SC1090
source "$rc_file"

echo "by ~"
